package cn.pegasus.teamwork.pegasus.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.pegasus.teamwork.pegasus.entity.BussRechargeConfig;
import cn.pegasus.teamwork.pegasus.mapper.BussRechargeConfigMapper;
import cn.pegasus.teamwork.pegasus.service.BussRechargeConfigService;
import cn.iyizhan.teamwork.base.service.impl.BaseServiceImpl;
import cn.iyizhan.teamwork.base.util.PageObject;

/**
 * @author ryan.bian
 * @version 
 */
@Service("bussRechargeConfigService")
public class BussRechargeConfigServiceImpl extends BaseServiceImpl<BussRechargeConfig, BussRechargeConfigMapper> implements BussRechargeConfigService {
	// 注入当前dao对象
    @Autowired
    private BussRechargeConfigMapper bussRechargeConfigMapper;

    public BussRechargeConfigServiceImpl() {
        setMapperClass(BussRechargeConfigMapper.class, BussRechargeConfig.class);
    }

	@Override
	public PageObject<BussRechargeConfig> PageList(Map<String, Object> map) {
		map.put("sortName", "create_time");
        map.put("sortOrder", "desc");
		return super.Pagequery(map);
	}

	@Override
	public void addRecharge(Long userId, BussRechargeConfig info) {
		info.setCreateTime(new Date());
		info.setCreateUserBy(userId);
		info.setUpdateTime(new Date());
		info.setUpdateUserBy(userId);
		info.setConfigStatus(0);
		bussRechargeConfigMapper.insertByEntity(info);
	}

	@Override
	public void updateRecharge(Long userId, BussRechargeConfig info) {
		info.setUpdateTime(new Date());
		info.setUpdateUserBy(userId);
		bussRechargeConfigMapper.updateByEntity(info);
		
	}

	@Override
	public void delete(Long userId, Integer id) {
		BussRechargeConfig info = new BussRechargeConfig();
		info.setUpdateTime(new Date());
		info.setUpdateUserBy(userId);
		info.setConfigStatus(1);
		info.setId(id);
		bussRechargeConfigMapper.updateByEntity(info);
	}

	@Override
	public BussRechargeConfig findInfo(Integer id) {
		BussRechargeConfig c = new BussRechargeConfig();
		c.setId(id);
		return bussRechargeConfigMapper.selectSingle(c);
	}

	@Override
	public List<BussRechargeConfig> findLists(Map<String, Object> map) {
		map.put("configStatus", 0);
		return bussRechargeConfigMapper.findLists(map);
	}
    
 
}
